package lesson02;

public class DisorderOhter {
    static int a = 0;
    static boolean flag = false;

    public static void main(String[] args) {

        long count = 0;
        while (true){
            a = 0;
            flag =false;
            count++;
            new Thread(new Runnable(){
                @Override
                public void run() {
                    a = 1;
                    flag = true;
                }
            }).start();
            if (flag && a == 0) {
                System.out.println("第 " + count + " 次, 指令重排序了, flag = "+ flag+", a="+a);
                break;
            }
        }

    }

}
